/*
* @Author: Srain
* @Date:   2018-07-12 17:04:32
* @Last Modified by:   Srain 
* @Last Modified time: 2018-09-23 11:08:24
*/

'use strict';

var _mm = require('util/mm.js');

var _user = {
    // 用户登录
    login : function(data,resolve, reject){
        _mm.request({
            url     : _mm.getServerUrl('/members/wz/login'),  
            data    : data,  
            method  : 'POST',
            success : resolve,
            error   : reject 
        });
    },
    // 检查登录状态
    checkLogin : function(resolve, reject){
        _mm.request({
            url     : _mm.getServerUrl('/members/wz/get_user_info'),
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    },
    // 检查用户名
    getStudentId : function(studentId, resolve, reject){
        _mm.request({
            url     : _mm.getServerUrl('/members/wz/forget_get_studentId'),
            data    : {
                type    : 'studentId',
                str     : studentId
            },
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    },
    // 检查答案
    checkAnswer : function(data,resolve, reject){
        _mm.request({
            url     : _mm.getServerUrl('/members/wz/forget_check_answer'),
            data    : data,
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    },
    // 重置密码
    resetPassword : function(data, resolve, reject){
        _mm.request({
            url     : _mm.getServerUrl('/members/wz/forget_reset_password'),
            data    : data,
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    },
    // 获取用户信息
    getUserInfo : function(resolve, reject){
        _mm.request({
            url     : _mm.getServerUrl('/members/wz/get_information'),
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    },
    // 更新个人信息
    updateUserInfo : function(data, resolve, reject){
        _mm.request({
            url     : _mm.getServerUrl('/members/wz/update_information'),
            data    : data,
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    },
    // 登录状态下更新密码
    updatePassword : function(data, resolve, reject){
        _mm.request({
            url     : _mm.getServerUrl('/members/wz/reset_password'),
            data    : data,
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    },
    // 登出
    logout : function(resolve, reject){
        _mm.request({
            url     : _mm.getServerUrl('/members/wz/logout'),
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    }
}
module.exports = _user;